package org.practice.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.practice.util.Constant;

public class OrderAction extends CartMappingDispatchAction{
	public ActionForward recipient(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return mapping.findForward("success");
	}

	public ActionForward confirmOrder(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return mapping.findForward("success");
	}

//	public ActionForward createOrder(ActionMapping mapping, ActionForm form,
//			HttpServletRequest request, HttpServletResponse response)
//			throws Exception {
//		HttpSession session = request.getSession();
//		Cart cart = (Cart) session.getAttribute(Constant.SESSION_KEY_CART);
//
//		if (cart == null) {
//			return mapping.findForward("fail");
//		}
//
//		OrderDao orderDao = ShopDaoFactory.getOrderDao();
//		Address address = new Address();
//		BeanUtils.copyProperties(address, form);
//		Order order = new Order();
//
//		List cartItems = cart.getItems();
//		Set items = new HashSet();
//		for (int i = 0; i < cartItems.size(); i++) {
//			Item item = new Item();
//			CartItem ct = (CartItem) cartItems.get(i);
//			item.setProduct(ct.getProduct());
//			item.setAmount(ct.getProduct().getDangPrice() * ct.getNumber());
//			item.setDangPrice(ct.getProduct().getDangPrice());
//			item.setNum(ct.getNumber());
//
//			items.add(item);
//		}
//
//		order.setItems(items);
//		
//		order.setAddress(address);
//		
//		User user = new User();
//		user.setId(cart.getUserId());
//		order.setUser(user);
//		
//		order.setCreateTime(System.currentTimeMillis());
//	
//		order.setOrderPrice(cart.getTotalPrice());
//		order.setTotalPrice(order.getOrderPrice()+0);
//
//		order.setStatus(1);
//		
//		orderDao.addOrder(order);
//		
//		cart.clear();
//		
//		return mapping.findForward("success");
//	}
}
